package net.repchain.browser.controller;

import com.github.pagehelper.PageInfo;
import net.repchain.browser.common.WebPageInfo;
import net.repchain.browser.common.config.ResultVO;
import net.repchain.browser.entity.RepchainBlock;
import net.repchain.browser.service.RepchainBlockService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (RepchainBlock)表控制层
 *
 * @author lhc
 * @since 2023-11-21 11:16:15
 */
@RestController
@RequestMapping("repchainBlock")
public class RepchainBlockController {
    /**
     * 服务对象
     */
    @Resource
    private RepchainBlockService repchainBlockService;

    /**
     * 分页查询
     *
     * @param repchainBlock 筛选条件
     * @param webPageInfo      分页对象
     * @return 查询结果
     */
    @GetMapping
    public ResultVO<PageInfo<RepchainBlock>> queryByPage(RepchainBlock repchainBlock, WebPageInfo webPageInfo) {
        return ResultVO.getSuccess(this.repchainBlockService.queryByPage(repchainBlock, webPageInfo));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param height 主键
     * @return 单条数据
     */
    @GetMapping("{height}")
    public ResultVO<RepchainBlock> queryById(@PathVariable("height") Long height) {
        return ResultVO.getSuccess(this.repchainBlockService.queryByHeight(height));
    }
}

